/*
 * Copyright (c) 2016. zhaojin 15398699939@163.com
 */

package com.bankscene.screenfit.dict;

/**
 * Created by jiiiiiin on 6/14/16.
 */
public enum ErrorDict {

    ERROR_LAYOUTVIEW_ISNULL(1, "视图容器对象不能为空!"),
    ERROR_COMPONENTVIEW_ISNULL(2, "查询的组件不存在!"),
    ERROR_COMPONENTIDCLAZZ_NOTMATH(3, "组件id和Clazz不匹配"),
    ERROR_LEFTFRAGMENT_NOTBENULL(4, "左侧的fragment不能为空!"),
    ERROR_RIGHTRAGMENT_NOTBENULL(5, "右侧的fragment不能为空!"),
    ERROR_UNBINDER_NOTBENULL(6, "butterknife unbinder为空!"),//!目前所有视图是给予fragment的
    ERROR_MENUSID_NOTBENULL(7, "查找菜单的菜单ID不能为空!"),
    ERROR_MENUSPOSITION_NOTBENULL(8, "查找菜单的Position不能为空!"),
    ERROR_SELETEDMENUS_NOTBENULL(9, "查找菜单的菜单不能为空!"),
    ERROR_SELECTEDMENUS_NOTBENULL(10, "选中的菜单对象作为参数不能为空!"),
    ERROR_RES_NOTISNULL(11, "服务器没有返回需要的数据!");

    private final int code;
    private final String msg;

    ErrorDict(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "[" + code + "]" + msg + "\n";
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static ErrorDict codeOf(int code) {
        for (ErrorDict dict : values()) {
            if (dict.getCode() == code) {
                return dict;
            }
        }
        return null;
    }
}
